//
//  NewsTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "NewsTableViewCell.h"
#import "UIView+UIViewSAAdditions.h"
#import "UIImageView+WebCache.h"
#import "LunBoPicture.h"

@implementation NewsTableViewCell

- (void)dealloc {
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.hearder];
        [self.hearder addSubview:self.scrollView];
        [self.hearder addSubview:self.scrollTitle];
        [self addSubview:self.title];
        [self addSubview:self.imgs];
        [self addSubview:self.digest];
        [_scrollView release];
        [_scrollTitle release];
        [_title release];
        [_imgs release];
        [_hearder release];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.imgs.frame = CGRectMake(10, 10, 130, 100);
    self.title.frame = CGRectMake(140, 10, 200, 40);
    self.digest.frame = CGRectMake(145, 60, 200, 60);
    self.scrollView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 20);
    self.scrollTitle.frame = CGRectMake(0, self.bottom, self.width, 20);
    
}






#pragma mark - prive
- (UILabel *)scrollTitle {
    if (!_scrollTitle) {
        self.scrollTitle = [[UILabel alloc] initWithFrame:CGRectZero];
    }
    return _scrollTitle;
}

- (UILabel *)title {
    if (!_title) {
        self.title = [[UILabel alloc] initWithFrame:CGRectZero];
        self.title.font = [UIFont systemFontOfSize:16];
        self.title.numberOfLines = 0;
    }
    return _title;
}

- (UIImageView *)scrollView {
    if (!_scrollView) {
        self.scrollView = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _scrollView;
}

- (UIImageView *)imgs {
    if (!_imgs) {
        self.imgs = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _imgs;
}
- (UIView *)hearder {
    if (!_hearder) {
        self.hearder = [[UIView alloc] initWithFrame:CGRectZero];
    }
    return _hearder;
}
- (UILabel *)digest {
    if (!_digest) {
        self.digest = [[UILabel alloc] initWithFrame:CGRectZero];
        self.digest.font = [UIFont systemFontOfSize:14];
        self.digest.numberOfLines = 0;
    }
    return _digest;
}


- (void)setNewsModel:(NewsModel *)newsModel {
    if (_newsModel != newsModel) {
        [_newsModel release];
        _newsModel = [newsModel retain];
    }
    self.title.text = newsModel.title;
    [self.imgs sd_setImageWithURL:[NSURL URLWithString:newsModel.imgsrc]];
    self.digest.text = newsModel.digest;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
